package name.sraynal.srt;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.regex.Matcher;

public class SrtAnalyzer {

	private BufferedReader reader;
	private String startDate = null; 
	private String endDate = null; 
	private String currentDate = null; 
	
	public SrtAnalyzer(String filePath) {
		try {
			reader = new BufferedReader(new FileReader(filePath));
			String line = null;
			
			while ((line = reader.readLine()) != null) {

				Matcher matcher = SrtModificator.LINE_PATTERN.matcher(line);
				
				if (matcher.matches()) {
					currentDate = matcher.group(1);
					
					if (startDate == null) {
						startDate = currentDate;
					}
				}
			}
			
			endDate = currentDate;
			reader.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public String getStartDate() {
		return startDate;
	}

	public String getEndDate() {
		return endDate;
	}
	
}
